package com.example.myapplication2;

import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;


public class weixinfragment extends Fragment {
        public RecyclerView recyclerView;
        private List<String> data, mess, infor;
        private Context context;
        private MyAdapter myadapter;
        private View view;
        private List image =new ArrayList();
        public weixinfragment() {
            // Required empty public constructor
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
            //获取fragment的layout
            view = inflater.inflate(R.layout.fragment_weixinfragment, container, false);
            //对recycleview进行配置
            context = this.getActivity();
            recyclerView = view.findViewById(R.id.recycler_View);
            data = new ArrayList<>();
            mess = new ArrayList<>();
            infor = new ArrayList<>();
            Random r=new Random();
            for (int i = 0; i < 10; i++) {
                image.add(R.mipmap.ic_launcher_round);
            }
            for (int i = 0; i < 10; i++) {
                data.add("Friend"+i);
            }

               mess.add("手机号:13545645542");
               mess.add("手机号:13543369942");
               mess.add("手机号:16546555542");
               mess.add("手机号:18456454542");
               mess.add("手机号:17844559442");
               mess.add("手机号:19865789994");
               mess.add("手机号:15499878485");
               mess.add("手机号:16584488951");
               mess.add("手机号:16599877775");
               mess.add("手机号:18546651994");

            for (int i=10;i<20;i++){
                String s;
                int m=r.nextInt(2);
                if (m==0)
                    s="在线";
                else s="离线";
                infor.add("状态:"+s);
            }

            myadapter = new MyAdapter(context, data,mess,infor,image);
            LinearLayoutManager layoutManager = new LinearLayoutManager(context,LinearLayoutManager.VERTICAL,false);
            recyclerView.setLayoutManager(layoutManager);
            recyclerView.setItemAnimator(new DefaultItemAnimator());
            recyclerView.setAdapter(myadapter);
            return view;
        }
    }



